<!DOCTYPE html>
<html class="wide wow-animation" lang="en">
  <head>
    <title>Single Product</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel="icon" href="/html/images/favicon.ico" type="image/x-icon">
    <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700%7CLato%7CKalam:300,400,700">
    <link rel="stylesheet" href="/html/css/bootstrap.css">
    <link rel="stylesheet" href="/html/css/fonts.css">
    <link rel="stylesheet" href="/html/css/style.css">
    <style>.ie-panel{display: none;background: #212121;padding: 10px 0;box-shadow: 3px 3px 5px 0 rgba(0,0,0,.3);clear: both;text-align:center;position: relative;z-index: 1;} html.ie-10 .ie-panel, html.lt-ie-10 .ie-panel {display: block;}</style>
  </head>
  <body>
    <div class="ie-panel"><a href="http://windows.microsoft.com/en-US/internet-explorer/"><img src="/html/images/ie8-panel/warning_bar_0000_us.jpg" height="42" width="820" alt="You are using an outdated browser. For a faster, safer browsing experience, upgrade for free today."></a></div>
    <div class="preloader">
      <div class="preloader-body">
        <div class="cssload-bell">
          <div class="cssload-circle">
            <div class="cssload-inner"></div>
          </div>
          <div class="cssload-circle">
            <div class="cssload-inner"></div>
          </div>
          <div class="cssload-circle">
            <div class="cssload-inner"></div>
          </div>
          <div class="cssload-circle">
            <div class="cssload-inner"></div>
          </div>
          <div class="cssload-circle">
            <div class="cssload-inner"></div>
          </div>
        </div>
      </div>
    </div>
    <div class="page">
      <!-- Page Header-->
      <header class="section page-header page-header-corporate">
        <!-- RD Navbar-->
        <div class="rd-navbar-wrap">
          <nav class="rd-navbar rd-navbar-corporate" data-layout="rd-navbar-fixed" data-sm-layout="rd-navbar-fixed" data-md-layout="rd-navbar-fixed" data-md-device-layout="rd-navbar-fixed" data-lg-layout="rd-navbar-static" data-lg-device-layout="rd-navbar-fixed" data-xl-layout="rd-navbar-static" data-xl-device-layout="rd-navbar-static" data-xxl-layout="rd-navbar-static" data-xxl-device-layout="rd-navbar-static" data-lg-stick-up-offset="154px" data-xl-stick-up-offset="182px" data-xxl-stick-up-offset="214px" data-lg-stick-up="true" data-xl-stick-up="true" data-xxl-stick-up="true">
            <div class="rd-navbar-collapse-toggle rd-navbar-fixed-element-1" data-rd-navbar-toggle=".rd-navbar-collapse"><span></span></div>
            <div class="rd-navbar-aside-outer">
              <div class="rd-navbar-aside">
                <p>Opening hours: Monday - Friday: 08AM-06PM</p>
                <div>
                  <div class="group-xs group-middle">
                    <p class="rd-navbar-basket-text">Your Cart is Empty</p>
                    <!-- RD Navbar Basket-->
                    <div class="rd-navbar-basket-wrap">
                      <button class="rd-navbar-basket fl-bigmug-line-shopping202" data-rd-navbar-toggle=".cart-inline"><a class="rd-nav-link" href="../shopping/cart">2</a>></button>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="rd-navbar-main-outer">
              <div class="rd-navbar-main">
                <div class="rd-navbar-main-element">
                  <!-- RD Navbar Panel-->
                  <div class="rd-navbar-panel">
                    <!-- RD Navbar Toggle-->
                    <button class="rd-navbar-toggle" data-rd-navbar-toggle=".rd-navbar-nav-wrap"><span></span></button>
                    <!-- RD Navbar Brand-->
                    <div class="rd-navbar-brand">
                      <!--Brand--><a class="brand" href="index.html"><img class="brand-logo-dark" src="/html/images/logo-default-5-286x124.png" alt="" width="143" height="62"/><img class="brand-logo-light" src="/html/images/logo-inverse-5-286x124.png" alt="" width="143" height="62"/></a>
                    </div>
                  </div>
                  <div class="rd-navbar-collapse">
                    <ul class="contacts-amber">
                      <li><a href="#">523 Sylvan Ave, 5th Floor<br/>Mountain View, CA 94041 USA</a></li>
                      <li><a href="tel:#">+1 (844) 123 456 78</a><br/><a href="mailto:#">info@demolink.org</a></li>
                    </ul>
                  </div>
                </div>
                <div class="rd-navbar-nav-wrap">
                  <ul class="rd-navbar-nav" style="justify-content: center; width: 100%;">
                    <li class="rd-nav-item"><a class="rd-nav-link" href="index">Home</a></li>
                    <li class="rd-nav-item active"><a class="rd-nav-link" href="shop">Shop</a></li>
                  </ul>
                </div>
              </div>
            </div>
          </nav>
        </div>
      </header>

      <!-- 原来的商品展示部分被替换为 -->
      <section class="section section-xxl bg-default">
        <div class="single-product-area">
          <div class="container">
            <div class="row">
              <!-- 左侧商品图片 -->
              <div class="col-md-6">
                <div class="product-details-image">
                  <img id="product-image" src="" alt="商品图片" />
                </div>
              </div>
              <!-- 右侧商品信息 -->
              <div class="col-md-6">
                <div class="product-details-content">
                  <h2 id="product-name"></h2>
                  <div class="price-box">
                    <span class="price" id="product-price"></span>
                  </div>
                  <div class="product-description">
                    <p id="product-description"></p>
                  </div>
                  <div class="add-to-cart">
                    <button type="button" onclick="addToCart()" class="button button-primary">加入购物车</button>
                  </div>

                </div>
              </div>
            </div>
          </div>
        </div>
      </section>
      <!-- Single Product-->
      <!--<section class="section section-sm section-first bg-default">
        <div class="container">
          <div class="row row-30">
            <div class="col-lg-6">
              <div class="slick-vertical slick-product">
                &lt;!&ndash; Slick Carousel&ndash;&gt;
                <div class="slick-slider carousel-parent" id="carousel-parent" data-items="1" data-swipe="true" data-child="#child-carousel" data-for="#child-carousel">
                  <div class="item">
                    <div class="slick-product-figure"><img src="/html/images/single-product-1-530x480.png" alt="" width="530" height="480"/>
                    </div>
                  </div>
                  <div class="item">
                    <div class="slick-product-figure"><img src="/html/images/single-product-2-530x480.jpg" alt="" width="530" height="480"/>
                    </div>
                  </div>
                  <div class="item">
                    <div class="slick-product-figure"><img src="/html/images/single-product-3-530x480.jpg" alt="" width="530" height="480"/>
                    </div>
                  </div>
                </div>
                <div class="slick-slider child-carousel slick-nav-1" id="child-carousel" data-arrows="true" data-items="3" data-sm-items="3" data-md-items="3" data-lg-items="3" data-xl-items="3" data-xxl-items="3" data-md-vertical="true" data-for="#carousel-parent">
                  <div class="item">
                    <div class="slick-product-figure"><img src="/html/images/single-product-1-530x480.png" alt="" width="530" height="480"/>
                    </div>
                  </div>
                  <div class="item">
                    <div class="slick-product-figure"><img src="/html/images/single-product-2-530x480.jpg" alt="" width="530" height="480"/>
                    </div>
                  </div>
                  <div class="item">
                    <div class="slick-product-figure"><img src="/html/images/single-product-3-530x480.jpg" alt="" width="530" height="480"/>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="col-lg-6">
              <div class="single-product">
                <h3 class="text-transform-none font-weight-medium">Oranges</h3>
                <div class="group-md group-middle">
                  <div class="single-product-price">$20</div>
                  <div class="single-product-rating"><span class="icon mdi mdi-star"></span><span class="icon mdi mdi-star"></span><span class="icon mdi mdi-star"></span><span class="icon mdi mdi-star"></span><span class="icon mdi mdi-star-half"></span></div>
                </div>
                <p>Lorem ipsum dolor sit amet, ei impetus epicurei his, ne falli erant consequuntur est. Mei simul aperiam eu, an rebum regione ponderum mel. Facer placerat ut duo, id duis solum maiorum vis, vim autemsemper docendi cu. Pro</p>
                <hr class="hr-gray-100">
                <ul class="list list-description">
                  <li><span>Category:</span><span>Citrus</span></li>
                  <li><span>Weight:</span><span>1 kg</span></li>
                  <li><span>Box:</span><span>60 x 60 x 90 cm</span></li>
                </ul>
                <div class="group-xs group-middle">
                  <div class="product-stepper">
                    <input class="form-input" type="number" data-zeros="true" value="1" min="1" max="1000">
                  </div>
                  <div><a class="button button-lg button-primary button-zakaria" href="#">Add to cart</a></div>
                </div>
                <hr class="hr-gray-100">
                <div class="group-xs group-middle"><span class="list-social-title">Share</span>
                  <div>
                    <ul class="list-inline list-social list-inline-sm">
                      <li><a class="icon mdi mdi-facebook" href="#"></a></li>
                      <li><a class="icon mdi mdi-twitter" href="#"></a></li>
                      <li><a class="icon mdi mdi-instagram" href="#"></a></li>
                      <li><a class="icon mdi mdi-google-plus" href="#"></a></li>
                    </ul>
                  </div>
                </div>
              </div>
            </div>
          </div>
          &lt;!&ndash; Bootstrap tabs&ndash;&gt;
          <div class="tabs-custom tabs-horizontal tabs-line" id="tabs-1">
            &lt;!&ndash; Nav tabs&ndash;&gt;
            <div class="nav-tabs-wrap">
              <ul class="nav nav-tabs nav-tabs-1">
                <li class="nav-item" role="presentation"><a class="nav-link active" href="#tabs-1-1" data-toggle="tab">Reviews</a></li>
                <li class="nav-item" role="presentation"><a class="nav-link" href="#tabs-1-2" data-toggle="tab">Additional information</a></li>
                <li class="nav-item" role="presentation"><a class="nav-link" href="#tabs-1-3" data-toggle="tab">Delivery and payment</a></li>
              </ul>
            </div>
            &lt;!&ndash; Tab panes&ndash;&gt;
            <div class="tab-content tab-content-1">
              <div class="tab-pane fade show active" id="tabs-1-1">
                <div class="box-comment">
                  <div class="unit flex-column flex-sm-row unit-spacing-md">
                    <div class="unit-left"><a class="box-comment-figure" href="#"><img src="/html/images/user-1-119x119.jpg" alt="" width="119" height="119"/></a></div>
                    <div class="unit-body">
                      <div class="group-sm group-justify">
                        <div>
                          <div class="group-xs group-middle">
                            <h5 class="box-comment-author"><a href="#">Jane Doe</a></h5>
                            <div class="box-rating"><span class="icon mdi mdi-star"></span><span class="icon mdi mdi-star"></span><span class="icon mdi mdi-star"></span><span class="icon mdi mdi-star"></span><span class="icon mdi mdi-star-half"></span></div>
                          </div>
                        </div>
                        <div class="box-comment-time">
                          <time datetime="2020-11-30">Nov 30, 2020</time>
                        </div>
                      </div>
                      <p class="box-comment-text">A falsis, hilotae fidelis historia. Detriuss experimentum, tanquam camerarius zeta. Ventuss nocere in brevis amivadum! Ubi est emeritis valebat? Adgiums messis, tanquam lotus rumor. Cum solitudo credere, omnes caculaes resuscitabo mirabilis, ferox plasmatores.</p>
                    </div>
                  </div>
                </div>
                <h4 class="text-transform-none font-weight-medium">Leave a Review</h4>
                <form class="rd-form rd-mailform" data-form-output="form-output-global" data-form-type="contact" method="post" action="bat/rd-mailform.php">
                  <div class="row row-20 row-md-30">
                    <div class="col-lg-8">
                      <div class="row row-20 row-md-30">
                        <div class="col-sm-6">
                          <div class="form-wrap">
                            <input class="form-input" id="contact-first-name-2" type="text" name="name" data-constraints="@Required"/>
                            <label class="form-label" for="contact-first-name-2">First Name</label>
                          </div>
                        </div>
                        <div class="col-sm-6">
                          <div class="form-wrap">
                            <input class="form-input" id="contact-last-name-2" type="text" name="name" data-constraints="@Required"/>
                            <label class="form-label" for="contact-last-name-2">Last Name</label>
                          </div>
                        </div>
                        <div class="col-sm-6">
                          <div class="form-wrap">
                            <input class="form-input" id="contact-email-2" type="email" name="email" data-constraints="@Email @Required"/>
                            <label class="form-label" for="contact-email-2">E-mail</label>
                          </div>
                        </div>
                        <div class="col-sm-6">
                          <div class="form-wrap">
                            <input class="form-input" id="contact-phone-2" type="text" name="phone" data-constraints="@Numeric"/>
                            <label class="form-label" for="contact-phone-2">Phone</label>
                          </div>
                        </div>
                      </div>
                    </div>
                    <div class="col-lg-4">
                      <div class="form-wrap">
                        <label class="form-label" for="contact-message-2">Message</label>
                        <textarea class="form-input textarea-lg" id="contact-message-2" name="phone" data-constraints="@Required"></textarea>
                      </div>
                    </div>
                  </div>
                  <button class="button button-lg button-primary button-zakaria" type="submit">Submit</button>
                </form>
              </div>
              <div class="tab-pane fade" id="tabs-1-2">
                <div class="single-product-info">
                  <div class="unit unit-spacing-md flex-column flex-sm-row align-items-sm-center">
                    <div class="unit-left"><span class="icon icon-80 mdi mdi-information-outline"></span></div>
                    <div class="unit-body">
                      <p>Racana, rector, et secula. A falsis, adelphis castus valebat. Secula germanus acipenser est. Abactuss assimilant, tanquam fatalis ignigena. Luras messis in mirabilis brigantium! Indexs peregrinatione, tanquam brevis deus. Devatios observare! Velum grauiter ducunt ad ferox triticum. Byssuss sunt ignigenas de castus amor. Hercle, impositio velox!. Heu, raptus index! Neuter galatae velox talems ionicis tormento est. Lotus, clemens habenas nunquam reperire de domesticus, fatalis absolutio.</p>
                    </div>
                  </div>
                </div>
              </div>
              <div class="tab-pane fade" id="tabs-1-3">
                <div class="single-product-info">
                  <div class="unit unit-spacing-md flex-column flex-sm-row align-items-sm-center">
                    <div class="unit-left"><span class="icon icon-80 mdi mdi-truck-delivery"></span></div>
                    <div class="unit-body">
                      <p>Species neuter urbs est. Medicinas prarere in quadrata! Ollas accelerare in azureus cella! Est fortis decor, cesaris. Unda nunquam ducunt ad brevis elogium. Hercle, bubo germanus!, brevis fluctui! Emeritis bromiums ducunt ad historia. Nunquam imperium amicitia. Spatiis experimentum, tanquam germanus sectam. Pol, superbus saga! Mortems accelerare in burdigala! Fidelis, superbus guttuss solite magicae de varius, grandis secula. Cum gluten persuadere, omnes aususes gratia azureus, fidelis lumenes.</p>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </section>-->
      <!-- Related Products-->
      <!--<section class="section section-sm section-last bg-default">
        <div class="container">
          <h4 class="font-weight-sbold">Featured Products</h4>
          <div class="row row-lg row-30 row-lg-50 justify-content-center">
            <div class="col-sm-6 col-md-5 col-lg-3">
              &lt;!&ndash; Product&ndash;&gt;
              <article class="product">
                <div class="product-body">
                  <div class="product-figure"><img src="/html/images/product-5-204x156.png" alt="" width="204" height="156"/>
                  </div>
                  <h5 class="product-title"><a href="single-product.html">Strawberries</a></h5>
                  <div class="product-price-wrap">
                    <div class="product-price">$17.00</div>
                  </div>
                </div>
                <div class="product-button-wrap">
                  <div class="product-button"><a class="button button-secondary button-zakaria fl-bigmug-line-search74" href="single-product.html"></a></div>
                  <div class="product-button"><a class="button button-primary button-zakaria fl-bigmug-line-shopping202" href="#"></a></div>
                </div>
              </article>
            </div>
            <div class="col-sm-6 col-md-5 col-lg-3">
              &lt;!&ndash; Product&ndash;&gt;
              <article class="product">
                <div class="product-body">
                  <div class="product-figure"><img src="/html/images/product-1-220x160.png" alt="" width="220" height="160"/>
                  </div>
                  <h5 class="product-title"><a href="single-product.html">Bananas</a></h5>
                  <div class="product-price-wrap">
                    <div class="product-price product-price-old">$32.00</div>
                    <div class="product-price">$22.00</div>
                  </div>
                </div><span class="product-badge product-badge-sale">Sale</span>
                <div class="product-button-wrap">
                  <div class="product-button"><a class="button button-secondary button-zakaria fl-bigmug-line-search74" href="single-product.html"></a></div>
                  <div class="product-button"><a class="button button-primary button-zakaria fl-bigmug-line-shopping202" href="#"></a></div>
                </div>
              </article>
            </div>
            <div class="col-sm-6 col-md-5 col-lg-3">
              &lt;!&ndash; Product&ndash;&gt;
              <article class="product">
                <div class="product-body">
                  <div class="product-figure"><img src="/html/images/product-2-224x123.png" alt="" width="224" height="123"/>
                  </div>
                  <h5 class="product-title"><a href="single-product.html">Pineapple</a></h5>
                  <div class="product-price-wrap">
                    <div class="product-price product-price-old">$23.00</div>
                    <div class="product-price">$30.00</div>
                  </div>
                </div><span class="product-badge product-badge-sale">Sale</span>
                <div class="product-button-wrap">
                  <div class="product-button"><a class="button button-secondary button-zakaria fl-bigmug-line-search74" href="single-product.html"></a></div>
                  <div class="product-button"><a class="button button-primary button-zakaria fl-bigmug-line-shopping202" href="#"></a></div>
                </div>
              </article>
            </div>
            <div class="col-sm-6 col-md-5 col-lg-3">
              &lt;!&ndash; Product&ndash;&gt;
              <article class="product">
                <div class="product-body">
                  <div class="product-figure"><img src="/html/images/product-9-185x155.png" alt="" width="185" height="155"/>
                  </div>
                  <h5 class="product-title"><a href="single-product.html">Galia melons</a></h5>
                  <div class="product-price-wrap">
                    <div class="product-price">$18.00</div>
                  </div>
                </div>
                <div class="product-button-wrap">
                  <div class="product-button"><a class="button button-secondary button-zakaria fl-bigmug-line-search74" href="single-product.html"></a></div>
                  <div class="product-button"><a class="button button-primary button-zakaria fl-bigmug-line-shopping202" href="#"></a></div>
                </div>
              </article>
            </div>
          </div>
        </div>
      </section>-->
      <!-- Page Footer-->
      <!--<footer class="section footer-corporate footer-corporate-2 context-dark">
        <div class="footer-corporate-body section-lg">
          <div class="container">
            <div class="row row-40 row-md-50 justify-content-xl-between">
              <div class="col-sm-6 col-lg-4 wow fadeInRight">
                <h5 class="footer-corporate-title">Visit our farm</h5>
                <div class="footer-corporate-decor"></div>
                <ul class="footer-corporate-info">
                  <li>
                    <div class="unit flex-column flex-sm-row align-items-center">
                      <div class="unit-left"><span class="icon mdi mdi-map-marker"></span></div>
                      <div class="unit-body"><a href="#">523 Sylvan Ave, 5th Floor<br/>Mountain View, CA 94041 USA</a></div>
                    </div>
                  </li>
                  <li>
                    <div class="unit flex-column flex-sm-row align-items-center">
                      <div class="unit-left"><span class="icon mdi mdi-clock"></span></div>
                      <div class="unit-body">
                        <ul class="list-schedule">
                          <li><span>Weekdays:</span><span>08:00am - 08:00pm</span></li>
                          <li><span>Weekends:</span><span>10:00am - 06:00pm</span></li>
                        </ul>
                      </div>
                    </div>
                  </li>
                </ul>
              </div>
              <div class="col-sm-6 col-lg-4 wow fadeInRight" data-wow-delay=".1s">
                <h5 class="footer-corporate-title">Quick links</h5>
                <div class="footer-corporate-decor"></div>
                <ul class="footer-corporate-list d-sm-inline-block d-md-block">
                  <li><a href="about-us.html">History</a></li>
                  <li><a href="#">FAQ</a></li>
                  <li><a href="our-team.html">Farmers</a></li>
                  <li><a href="#">Events</a></li>
                  <li><a href="blog.html">Blog</a></li>
                  <li><a href="#">Organic Fruits</a></li>
                  <li><a href="#">Our Smoothies</a></li>
                  <li><a href="#">Fruit Boxes</a></li>
                  <li><a href="#">Yoghurts</a></li>
                </ul>
              </div>
              <div class="col-lg-4 wow fadeInRight" data-wow-delay=".2s">
                <h5 class="footer-corporate-title">Get in touch</h5>
                <div class="footer-corporate-decor"></div>
                <p class="footer-corporate-text">We are always ready  to answer any questions you may have or help you select organic fruits.</p>
                <div class="group-sm group-middle"><a class="button button-shadow-2 button-gray-14 button-zakaria" href="shopping/shop">Shop now</a><a class="button button-shadow-2 button-primary-2 button-zakaria" href="contact-us.html">Contact us</a></div>
              </div>
            </div>
          </div>
        </div>
        <div class="footer-corporate-panel">
          <div class="container">
            <div class="row row-10 row-sm-30 align-items-center justify-content-sm-between">
              <div class="col-sm-auto col-lg-4 text-lg-left">
                <div class="group-xs group-middle"><img src="/html/images/payment-1-45x15.png" alt="" width="45" height="15"/><img src="/html/images/payment-2-46x28.png" alt="" width="46" height="28"/><img src="/html/images/payment-3-62x17.png" alt="" width="62" height="17"/>
                </div>
              </div>
              <div class="col-sm-auto col-lg-4">
                <ul class="list-inline list-social-4 list-inline-xs">
                  <li><a class="icon mdi mdi-facebook icon-xxs" href="#"></a></li>
                  <li><a class="icon mdi mdi-twitter icon-xxs" href="#"></a></li>
                  <li><a class="icon mdi mdi-instagram icon-xxs" href="#"></a></li>
                  <li><a class="icon mdi mdi-google-plus icon-xxs" href="#"></a></li>
                  <li><a class="icon mdi mdi-skype icon-xxs" href="#"></a></li>
                </ul>
              </div>
              <div class="col-lg-4 text-lg-right">
                <p class="rights"><span>&copy;&nbsp; </span><span class="copyright-year"></span><span>&nbsp;</span><span>Orange</span><span>.&nbsp; All rights reserved.</span><span>&nbsp;</span><a href="privacy-policy.html">Privacy Policy</a><span>.</span> <a target="_blank" href="https://www.mobanwang.com/" title="网站模板">网站模板</a></p>
              </div>
            </div>
          </div>
        </div>
      </footer>-->
    </div>
    <div class="snackbars" id="form-output-global"></div>
    <script src="/html/js/core.min.js"></script>
    <script src="/html/js/script.js"></script>

    <script src="/layui/layui.all.js"></script>

    <script>
      $(document).ready(function() {
        const urlParams = new URLSearchParams(window.location.search);
        const productId = urlParams.get('productid');

        if (productId) {
          $.ajax({
            url: '/product/getProductById',
            method: 'GET',
            data: { productid: productId },
            success: function(response) {
              // 直接使用 response，因为返回的就是商品对象
              if (response) {
                const product = response;  // 不需要 response.data
                // 更新页面内容
                $('#product-image').attr('src', '../' + product.imgurl);
                $('#product-name').text(product.name);
                $('#product-price').text('￥' + product.price.toFixed(2));
                $('#product-description').text(product.productaddress || '暂无商品描述');

                // 更新页面标题
                document.title = product.name + ' - 商品详情';

                // 更新面包屑导航
                $('.breadcrumbs-custom-title').text(product.name);
                $('.breadcrumbs-custom-path .active').text(product.name);
              } else {
                layer.msg('商品信息加载失败');
                setTimeout(() => {
                  window.location.href = '/shopping/shop';
                }, 2000);
              }
            },
            error: function(xhr, status, error) {
              layer.msg('加载失败，请稍后重试');
              console.error('Error:', error);
              setTimeout(() => {
                window.location.href = '/shopping/shop';
              }, 2000);
            }
          });
        } else {
          layer.msg('商品ID不存在');
          setTimeout(() => {
            window.location.href = '/shopping/shop';
          }, 2000);
        }
      });
      // 添加到购物车的函数
      // ... 其他代码保持不变 ...

      function addToCart() {
        const productId = new URLSearchParams(window.location.search).get('productid');

        if (!productId) {
          layer.msg('参数错误');
          return;
        }

        $.ajax({
          url: '/cart/add',
          method: 'POST',
          data: {
            productid: productId,
            count: 1  // 直接设置数量为1，不再从输入框获取
          },
          success: function(response) {
            /*if (response.code === 200) {*/
              layer.msg('添加购物车成功');
           /* } else if (response.code === 401) {
              layer.msg('请先登录');
              setTimeout(() => {
                window.location.href = '/login';
              }, 1500);
            } else {
              layer.msg(response.msg || '添加失败');
            }*/
          },
          error: function(xhr) {
            if (xhr.status === 401) {
              layer.msg('请先登录');
              setTimeout(() => {
                window.location.href = '/login';
              }, 1500);
            } else {
              layer.msg('添加失败，请稍后重试');
              console.error('Error:', xhr.responseText);
            }
          }
        });
      }

      // ... 其他代码保持不变 ...
    </script>

  </body>
</html>